home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue66 / Alfresco / Project1.dpr < prev   
Encoding:
Text File  |  2000-12-30  |  1.2 KB  |  60 lines

  1. program Project1;
  2.  
  3. {$apptype console}
  4.  
  5. uses
  6.   SysUtils,
  7.   AARegex in 'AARegex.pas';
  8.  
  9. var
  10.   P : TaaRegexParser;
  11.   RC : TaaRegexCompiler;
  12.   i : integer;
  13.   S : string;
  14.   F : text;
  15.   ec : TaaRegexError;
  16. begin
  17.   (*
  18.   S := '(a*[a-z]+)|g?[(ab';
  19.   P := TaaRegexParser.Create(S);
  20.   if not P.Parse(i) then begin
  21.     writeln('error found at ', i);
  22.     writeln(S);
  23.     for i := 1 to length(S) do
  24.       write(i mod 10);
  25.     writeln;
  26.   end;
  27.   P.Free;
  28.   readln;
  29.   *)
  30. //  S := '([a-zA-Z]+\^)|([A-Za-z]+\.[A-Za-z])';
  31. //  S := '.*(true|false);[ ]*$';
  32.   S := '^ *(function|procedure) +[^.]*$';
  33. //  S := 'if.*then( *| begin *)$';
  34. //  S := 'while.*do( *| begin *)$';
  35. //  S := '^[^ A-Z]*$';
  36. //  S := '^( *|.*:= *)rcSetState';
  37.   RC := TaaRegexCompiler.Create(S);
  38.   if not RC.Parse(i, ec) then begin
  39.     writeln('error found at ', i);
  40.     writeln(S);
  41.     for i := 1 to length(S) do
  42.       write(i mod 10);
  43.     writeln;
  44.   end
  45.   else begin
  46.     RC.IgnoreCase := true;
  47.     System.Assign(F, 'AARegEx.pas');
  48.     System.Reset(F);
  49.     while not eof(F) do begin
  50.       readln(F, S);
  51.       i := RC.MatchString(S);
  52.       if (i <> 0) then
  53.         writeln(i:2, ' ', S);
  54.     end;
  55.     System.Close(F);
  56.   end;
  57.   RC.Free;
  58.   readln;
  59. end.
  60.